﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Max.PH6_2006A.LowCode.DataAccess
{
    public class DapperFactory
    {
        public static IDbConnection Instance(string type, string strConnection)
        {
            #region 常规写法

            //IDbConnection dbConnection;
            //switch (type.ToLower())
            //{
            //    case "mysql":
            //        dbConnection = new MySqlConnection(strConnection);
            //        break;
            //    default:
            //        dbConnection = new SqlConnection(strConnection);
            //        break;
            //}
            #endregion

            //表达式简写
            IDbConnection dbConnection = type.ToLower() switch
            {
                "mysql" => new MySqlConnection(strConnection),
                _ => new SqlConnection(strConnection),
            };
            return dbConnection;
        }
    }
}
